<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta charset="utf-8"/>
    <title>管理系统</title>

    <meta name="description" content=""/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"/>
    <link rel="stylesheet" th:href="@{/css/bootstrap.min.css}"/>
    <link rel="stylesheet" th:href="@{/font-awesome/4.5.0/css/font-awesome.min.css}"/>
    <link rel="stylesheet" th:href="@{/css/fonts.googleapis.com.css}"/>
    <link rel="stylesheet" th:href="@{/css/ace.min.css}" class="ace-main-stylesheet" id="main-ace-style"/>
    <link rel="stylesheet" th:href="@{/css/ace-part2.min.css}" class="ace-main-stylesheet"/>
    <link rel="stylesheet" th:href="@{/css/ace-skins.min.css}"/>
    <link rel="stylesheet" th:href="@{/css/ace-rtl.min.css}"/>
    <link rel="stylesheet" th:href="@{/css/ace-ie.min.css}"/>
    <link rel="stylesheet" th:href="@{/css/dataTables.bootstrap4.min.css}"/>
    <script th:src="@{/js/ace-extra.min.js}"></script>
    <script th:src="@{/js/html5shiv.min.js}"></script>
    <script th:src="@{/js/respond.min.js}"></script>
</head>

<body class="no-skin">
<!--头导航栏-->
<div th:replace="common/bar::#navbar"></div>
<div class="main-container ace-save-state" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.loadState('main-container')
        } catch (e) {
        }
    </script>
    <!-- 侧导航栏 -->
    <div th:replace="common/bar::#sidebar"></div>

    <div class="main-content">
        <div class="main-content-inner">
            <div class="breadcrumbs ace-save-state" id="breadcrumbs">
                <ul class="breadcrumb">
                    <li>
                        <i class="ace-icon fa fa-home home-icon"></i>
                        <a href="#">sys</a>
                    </li>
                    <li class="active">index</li>
                </ul><!-- /.breadcrumb -->
            </div>
            <div class="modal fade" id="report_preview_modal">
                <div class="modal-dialog modal-lg">
                    <div class="modal-content">
                        <!-- 模态框头部 -->
                        <div class="modal-header">
                            <h4 class="modal-title">模板预览-编辑无效-下载后自行编辑</h4>
                            <button type="button" class="close" data-dismiss="modal">&times;</button>
                        </div>
                        <!-- 模态框主体 -->
                        <div class="modal-body">
                            <div id="report_preview">
                            </div>
                        </div>
                        <!-- 模态框底部 -->
                        <div class="modal-footer">
                            <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
                        </div>
                    </div>
                </div>
            </div>
            <div class="page-content">
                <div class="row">
                    <div class="col-xs-12 col-sm-3 widget-box">
                        <div class="widget-header">
                            <h4 class="widget-title" style="color: black">选择分类</h4>
                        </div>
                        <select class="form-control" id="select_client" multiple="multiple" style="height:0px;padding-bottom: 100%;">
                        </select>
                    </div>
                    <div class="col-xs-12 col-sm-9">
                        <div class="table-responsive col-sm-12">
                            <table class="table table-bordered table-hover text-nowrap" id="report_table"
                                   cellspacing="0">
                                <thead>
                                <tr>
                                    <th>原始报告id</th>
                                    <th>报告编号</th>
                                    <th>编制人</th>
                                    <th>委托单位</th>
                                    <th>报告</th>
                                    <th>审核人</th>
                                    <th>签发人</th>
                                    <th>备注</th>
                                    <th>提交时间</th>
                                    <th>状态</th>
                                </tr>
                                </thead>
                                <tbody>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->

    <div class="footer">
        <div class="footer-inner">
            <div class="footer-content">
                <span class="bigger-120">
                    <span class="blue bolder">Ace</span>
                    管理系统 &copy; 2020
                </span>
            </div>
        </div>
    </div>

    <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
        <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
    </a>
</div><!-- /.main-container -->
<script th:src="@{/js/jquery-2.1.4.min.js}"></script>
<script th:src="@{/js/jquery-1.11.3.min.js}"></script>
<script th:src="@{/js/bootstrap.min.js}"></script>
<script th:src="@{/js/ace-elements.min.js}"></script>
<script th:src="@{/js/ace.min.js}"></script>
<script th:src="@{/js/PDFObject.js}"></script>
<script th:src="@{/js/jquery.dataTables.min.js}"></script>
<script th:src="@{/js/jquery.dataTables.bootstrap.min.js}"></script>
</body>
<script>
    function load_report_table(url) {
        var table;
        //提示信息
        $.fn.dataTable.ext.errMode = 'none';
        var lang = {
            "bAutoWidth": false,
            "sProcessing": "处理中...",
            "sLengthMenu": "每页 _MENU_ 项",
            "sZeroRecords": "没有匹配结果",
            "sInfo": "当前显示第 _START_ 至 _END_ 项，共 _TOTAL_ 项。",
            "sInfoEmpty": "当前显示第 0 至 0 项，共 0 项",
            "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
            "sInfoPostFix": "",
            "sSearch": "搜索:",
            "sUrl": "",
            "sEmptyTable": "表中数据为空",
            "sLoadingRecords": "载入中...",
            "sInfoThousands": ",",
            "oPaginate": {
                "sFirst": "首页",
                "sPrevious": "上页",
                "sNext": "下页",
                "sLast": "末页",
                "sJump": "跳转"
            },
            "oAria": {
                "sSortAscending": ": 以升序排列此列",
                "sSortDescending": ": 以降序排列此列"
            }
        };
        //初始化表格
        table = $("#report_table")
            .on("error.dt", function (e, settings, techNote, message) {
                console.warn(message)
            }).dataTable({
                destroy: true,
                autoWidth: false,
                language: lang, //提示信息
                processing: true, //隐藏加载提示,自行处理
                serverSide: false, //启用服务器端分页
                searching: true, //禁用原生搜索
                orderMulti: true, //启用多列排序
                pagingType: "full_numbers", //分页样式：simple,simple_numbers,full,full_numbers
                ajax: function (data, callback, settings) {
                    $.ajax({
                        type: "GET",
                        // url: "/vor/getMyVorList",
                        url: url,
                        cache: false, //禁用缓存
                        dataType: "json",
                        success: function (result) {
                            var returnData = {};
                            returnData.data = result;//返回的数据列表
                            console.log(result);
                            callback(returnData);
                        }
                    });
                },
                "columns": [
                    {"data": "reportId", visible: false},
                    {"data": "reportNumber"},
                    {"data": "holder"},
                    {"data": "clientName"},
                    {
                        "data": "path",
                        render: function (data, type, full) {
                            return "<a href='#' onclick='view_report_modal(" + "\"" + data + "\"" + ")'>点击查看</a>";
                        }

                    },
                    {"data": "checkName"},
                    {"data": "signName"},
                    {"data": "remark"},
                    {
                        "data": "createTime",
                        render: function (data, type, full) {
                            return new Date(data).toLocaleDateString();
                        }
                    },
                    {
                        "data": "status",
                        render: function (data, type, full) {
                            var temp = "";
                            switch (data) {
                                case 0:
                                    temp = "审核中...";
                                    break;
                                case 1:
                                    temp = "审核中...";
                                    break;
                                case 2:
                                    temp = "审核通过";
                                    break;
                                case 3:
                                    temp = "<span style='color: red'>不合格</span>";
                                    break;
                                case 4:
                                    temp = "签发成功";
                                    break;
                                case 5:
                                    temp = "<span style='color: red'>不合格</span>";
                                    break;
                                case 6:
                                    temp = "已归档";
                                    break;
                            }
                            return temp;
                        }

                    },
                ],
            }).api();
    };
    $(function () {
        //装载报告
        load_report_table("/report/getList");
        //装载选择委托单位
        $.ajax({
            type:"get",
            url:"/client/all",
            success:function (res) {
                $("#select_client").append("<option value='0'>所有</option>");
                $.each(res,function (index,item) {
                    $("#select_client").append("<option value='"+item.clientId+"'>"+item.clientName+"</option>");
                });
            }
        });
    });
    $("#select_client").change(function () {
        load_report_table("/report/getList?cid="+$(this).val());
    });
    function view_report_modal(path) {
        var options = {
            height: "500px",
            name: "mans",
            fallbackLink: "<p>您的浏览器暂不支持此pdf，请下载最新的浏览器</p>",
            forcePDFJS: true
        };
        // PDFObject.embed("http://120.53.7.83:8000" + path, "#report_preview", options);
        PDFObject.embed("http://localhost:8000" + path, "#report_preview", options);
        $("#report_preview_modal").modal("show");
    }
</script>
</html>
